package com.atguigu.gmall.task.schedul;

import com.atguigu.gmall.common.constant.MqConst;
import com.atguigu.gmall.common.service.RabbitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@EnableScheduling
public class ScheduledTask {

    @Autowired
    private RabbitService rabbitService;

    //秒 分 时 日 月 周 年

    @Scheduled(cron = "0/10 * * * * ?")
//    @Scheduled(cron = "0 0 1 * * ?")
    public void task(){
        System.out.println("开始上班。。。");
        rabbitService.sendMessage(MqConst.EXCHANGE_DIRECT_TASK,MqConst.ROUTING_TASK_1,"给你点事干");
    }
}
